package main.java.com.negromotad.view.tableModelView;

public class TableModelViewPartialResult extends TableModelView {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2769244999409713063L;

	public TableModelViewPartialResult(String[] col) {
		super(col);
		String[][] data = new String[1][col.length + 1];
		data[0][0] = "1";
		for (int i = 1; i <= col.length; i++) {
			data[0][i] = "-";
		}
		this.setData(data);
	}

	public void addRow(String[] newRow) {
		String[][] oldData = (String[][]) this.getData();
		String[][] newData = null;
		if (oldData[0][1].equals("-")) {
			newData = new String[this.getData().length][this.getColumnCount()];
		} else {
			newData = new String[this.getData().length + 1][this
					.getColumnCount()];
			for (int i = 0; i < oldData.length; i++) {
				for (int j = 0; j < this.getColumnCount(); j++) {
					newData[i][j] = oldData[i][j];
				}
			}
		}

		newData[newData.length - 1][0] = Integer.toString(newData.length);
		for (int i = 0; i < newRow.length; i++) {
			newData[newData.length - 1][i + 1] = newRow[i];
		}
		this.setData(newData);
	}

}
